package com.devicemantra.coordinate.jaxb;
import javax.xml.bind.*;


public class UnMarshalEventHandler implements ValidationEventHandler
{
	public UnMarshalEventHandler()
	{
		System.out.println("Unmarshaller object created now");
	}
	
	public void printLevel(int pLevel)
	{
		if(pLevel == ValidationEvent.ERROR)
			System.out.println("Level : ERROR ");
		
		if(pLevel == ValidationEvent.WARNING)
			System.out.println("Level : WARNING ");
		
		if(pLevel == ValidationEvent.FATAL_ERROR)
			System.out.println("Level : FATAL_ERROR ");
	}

	@Override
	public boolean handleEvent(ValidationEvent arg0) {
		// TODO Auto-generated method stub
		System.out.println("[UnMarshalEventHandler] " + arg0.getMessage());
		System.out.println("[UnMarshalEventHandler] " + arg0.getLocator());
		System.out.println("[UnMarshalEventHandler] " + arg0.getSeverity());
		printLevel(arg0.getSeverity());
		if(arg0.getSeverity() == 2)
			return false; 
		
		return true;
	}
	
	public void finalize()
	{
		System.out.println("I GOT GARBAGE COLLECTED NOW !!!");
	}
	
}
